﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;

namespace Brouteforce.Animation {
    public class LinearFrameAnimationTransition : Transition {

        public List<Texture2D> Textures;
        public double TextureSwitchDuration;

        public LinearFrameAnimationTransition(double duration, List<Texture2D> frames, double frameDuration) :base(duration) {
            Textures = frames;
            TextureSwitchDuration = frameDuration;
        }

        public override void interpolate(Microsoft.Xna.Framework.GameTime time) {
            var t = Time / Duration;
            Value = t;
        }

        public Texture2D CurrentTexture {
            get {
                int cframe = (int) (Value / TextureSwitchDuration);
                return Textures[cframe % Textures.Count];
            }
        }
    }
}
